<template>
	<div>
		<h3>系统通知</h3>
		<el-collapse>
			<el-collapse-item v-for="item in listData" :key="item.id">
				<template slot="title">
					<span style="font-weight: bold">{{ item.name }}</span><i class="header-icon el-icon-info"></i>
				</template>
				<div>发布时间：{{item.createTime}}</div>
				<div>发布内容：{{ item.content }}</div>
			</el-collapse-item>
		</el-collapse>
	</div>
</template>
<script>
	import tools from "@/utils/utils";
	export default {
		data() {
			return {
				listData: [],
				
			}
		},

		created() {
			// console.log(tools.getUserInfo(),009)
			if(tools.getUserInfo().roleType == 'USER'){
				this.$router.push({
					path: '/front/index',
				})
			}else{
				this.getPageList()
			}
			
		},
		mounted() {
		
		},
		methods: {
			getPageList() {
				this.$axios.get("/notice/list").then(res => {
					this.listData = res.data
				})
			},
			// connect() {
			// 	this.socket = new WebSocket('ws://172.20.1.60:1000');

			// 	this.socket.onopen = () => {
		 // 		console.log('WebSocket connection opened');
			// 	};

			// 	this.socket.onmessage = (event) => {
			// 		console.log('Message received:', event.data);
		 // 		this.messages.push(event.data);
			// 	};

			// 	this.socket.onclose = () => {
			// 		console.log('WebSocket connection closed');
			// 		// Optionally, try to reconnect here
			// 	};

			// 	this.socket.onerror = (error) => {
			// 		console.error('WebSocket error:', error);
		 // 	};
			// },
		}
	}
</script>
